<?php

use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return 'test';
})->middleware(\App\Http\Middleware\AuthCheck::class);

Route::post('/login', [\App\Http\Controllers\Login::class, 'login']);
Route::post('/logout', [\App\Http\Controllers\Login::class, 'logout']);

//检查权限并记录操作日志
Route::middleware([\App\Http\Middleware\AuthCheck::class, \App\Http\Middleware\OperateLogs::class])->group( function () {
    // 用户
    Route::get('/user', [\App\Http\Controllers\UserController::class, 'index']);
    Route::get('/user/{id}', [\App\Http\Controllers\UserController::class, 'show'])->where('id', '[0-9]+');
    Route::post('/user', [\App\Http\Controllers\UserController::class, 'store']);
    Route::put('/user/{id}', [\App\Http\Controllers\UserController::class, 'update'])->where('id', '[0-9]+');
    Route::put('/user/reset/{id}', [\App\Http\Controllers\UserController::class, 'reset'])->where('id', '[0-9]+');
    Route::delete('/user/{id}', [\App\Http\Controllers\UserController::class, 'destroy'])->where('id', '[0-9]+');
    // 部门
    Route::get('/department', [\App\Http\Controllers\DepartmentController::class, 'index']);
    Route::get('/department/{id}', [\App\Http\Controllers\DepartmentController::class, 'show']);
    Route::post('/department', [\App\Http\Controllers\DepartmentController::class, 'store']);
    Route::put('/department/{id}', [\App\Http\Controllers\DepartmentController::class, 'update']);
    Route::delete('/department/{id}', [\App\Http\Controllers\DepartmentController::class, 'destroy']);
    // 系统配置
    Route::get('/systemConfig', [\App\Http\Controllers\SystemConfigController::class, 'index']);
    Route::get('/systemConfig/{id}', [\App\Http\Controllers\SystemConfigController::class, 'show']);
    Route::post('/systemConfig', [\App\Http\Controllers\SystemConfigController::class, 'store']);
    Route::put('/systemConfig/{id}', [\App\Http\Controllers\SystemConfigController::class, 'update']);
    Route::delete('/systemConfig/{id}', [\App\Http\Controllers\SystemConfigController::class, 'destroy']);
    // 系统配置类型
    Route::get('/systemConfigType', [\App\Http\Controllers\SystemConfigTypeController::class, 'index']);
    Route::get('/systemConfigType/{id}', [\App\Http\Controllers\SystemConfigTypeController::class, 'show']);
    Route::post('/systemConfigType', [\App\Http\Controllers\SystemConfigTypeController::class, 'store']);
    Route::put('/systemConfigType/{id}', [\App\Http\Controllers\SystemConfigTypeController::class, 'update']);
    Route::delete('/systemConfigType/{id}', [\App\Http\Controllers\SystemConfigTypeController::class, 'destroy']);
    // 节点
    Route::get('/node', [\App\Http\Controllers\NodeController::class, 'index']);
    Route::get('/node/{id}', [\App\Http\Controllers\NodeController::class, 'show']);
    Route::post('/node', [\App\Http\Controllers\NodeController::class, 'store']);
    Route::put('/node/{id}', [\App\Http\Controllers\NodeController::class, 'update']);
    Route::delete('/node/{id}', [\App\Http\Controllers\NodeController::class, 'destroy']);
    // 角色
    Route::get('/role', [\App\Http\Controllers\RoleController::class, 'index']);
    Route::get('/role/{id}', [\App\Http\Controllers\RoleController::class, 'show']);
    Route::post('/role', [\App\Http\Controllers\RoleController::class, 'store']);
    Route::put('/role/{id}', [\App\Http\Controllers\RoleController::class, 'update']);
    Route::delete('/role/{id}', [\App\Http\Controllers\RoleController::class, 'destroy']);
    Route::post('/role/node/{id}', [\App\Http\Controllers\RoleController::class, 'node']);
});
